package com.study.bigdata.spark.streaming

import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Seconds, StreamingContext}

object SparkStreaming06_State_Transform {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("SparkStreaming")
    val ssc =new StreamingContext(sparkConf,Seconds(3))

    val lines = ssc.socketTextStream("localhost", 9999)
    //transform方法可以将底层的RDD获取后进行操作
    //1.DStream的功能不完善
    //2.需要代码周期性执行

    //Code:Driver端
    lines.transform(
      rdd =>{
        //Code:Driver（周期性执行）
        rdd.map(
          str =>{
            //Code:Executor端
            str
          }
        )
      }
    )

    ssc.start()
    ssc.awaitTermination()
  }
}
